/*
 * PFArray.h
 *
 *  Created on: Mar 1, 2014
 *      Author: Anthony Varghese - This is from the Savitch book
 */

#ifndef PFARRAY_H_
#define PFARRAY_H_

namespace PFArraySavitch {

template<class T>
class PFArray {
public:
	PFArray(); //Initializes with a capacity of 50.
	PFArray(int capacityValue);
	PFArray(const PFArray<T>& pfaObject);

	/**
	 * addElement
	 * Precondition: The array is not full.
	 * Postcondition: The element has been added.
	 */
	void addElement(T element);

	bool full() const; //Returns true if the array is full, false otherwise.
	int getCapacity() const;
	int getNumberUsed() const;

	/**
	 * Resets the number used to zero, effectively emptying the array.
	 *
	 */
	void emptyArray();

	/**
	 * [] operator
	 * Read and change access to elements 0 through numberUsed - 1.
	 */
	T& operator[](int index);

	PFArray<T>& operator =(const PFArray<T>& rightSide);

	virtual ~PFArray();
private:
	T *a; //for an array of T.
	int capacity; //for the size of the array.
	int used; //for the number of array positions currently in use.
};

} /* namespace PFArraySavitch */

#endif /* PFARRAY_H_ */
